import sys
n = input()
l = map(int,sys.stdin.readline().split())  
m = [0 for i in range(n)]
m[0] = l[0]
ans = 0
end = 0
for i in range(1,n):
	if m[i-1] + l[i] > l[i]:
		m[i] = m[i-1] + l[i]
	else:
		m[i] = l[i]
	if ans < m[i]:
		ans = m[i]
		end = i
res = ""
res += str(ans)
front = end
anss = ans
while anss >0:
	anss -= l[front]
	front -=1
	pass
front +=1
res += ' '+ str(front) + ' ' + str(end)
print res